/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.extra
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-30
 * @time 下午8:23:40
 */
package com.ssh.web.extra;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.entity.DLicence;
import com.ssh.entity.FcarAplly;
import com.ssh.entity.FcarDriver;
import com.ssh.entity.Vehicle;
import com.ssh.ser.extra.FVApplySerI;
import com.ssh.ser.inout.FVehicleMSerI;
import com.ssh.ser.inout.FcarDriverServiceI;

/**
 * @author jack
 * @desc 长期出入地方车提出申请action
 */
public class FVApplyAction extends ActionSupport {
	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private String applyReason;
	private String driverId;
	private FVApplySerI fVApplySerI;
	private String name;
	private String tel;
	private String type;
	private String vehicleId;
	private String vehiclePicture;
	private FVehicleMSerI fVehicleMSerI;

	public FVehicleMSerI getfVehicleMSerI() {
		return fVehicleMSerI;
	}

	public void setfVehicleMSerI(FVehicleMSerI fVehicleMSerI) {
		this.fVehicleMSerI = fVehicleMSerI;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		try {
			HttpServletRequest request = ServletActionContext.getRequest();
			driverId=request.getParameter("driverId");
			applyReason=request.getParameter("applyReason");
			name=request.getParameter("name");
			tel=request.getParameter("tel");
			type=request.getParameter("type");
			vehicleId=request.getParameter("vehicleId");
			vehiclePicture=request.getParameter("vehiclePicture");
			if (!driverId.equals("") && !vehicleId.equals("")) {
				DLicence dLicence = new DLicence();
				Vehicle vehicle = new Vehicle();
				FcarDriver fcarDriver = new FcarDriver();
				FcarAplly fcarAplly = new FcarAplly();
				//保存驾驶证上的信息  此处驾驶证号与驾驶员身份证号相同 其他信息暂无录入
				dLicence.setDlicenceId(driverId);

				//保存车的信息
				vehicle.setVehicleId(vehicleId);
				vehicle.setType(type);
				vehicle.setVehiclePicture(vehiclePicture);
                //保存驾驶员的信息
				fcarDriver.setCarId(vehicleId);
				fcarDriver.setDLicence(dLicence);
				fcarDriver.setDriverId(driverId);
				fcarDriver.setName(name);
				fcarDriver.setTel(tel);
                //保存申请信息
				fcarAplly.setFcarCarid(vehicleId);
				fcarAplly.setDLicence(dLicence);
				fcarAplly.setApplyDate(new Timestamp(System.currentTimeMillis()));
				fcarAplly.setApplyReason(applyReason);
				fcarAplly.setReviewerId("of00001");//定义默认处理申请账户
				fcarAplly.setApplyResult((short)1);

				fVApplySerI.iWantToFInOut(dLicence, vehicle, fcarDriver, fcarAplly);

//				fcarDriverServiceI.save(fcarDriver);
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}

	/**
	 * @return the applyReason
	 */
	public String getApplyReason() {
		return applyReason;
	}

	/**
	 * @return the driverId
	 */
	public String getDriverId() {
		return driverId;
	}

	/**
	 * @return the fVApplySerI
	 */
	public FVApplySerI getfVApplySerI() {
		return fVApplySerI;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the tel
	 */
	public String getTel() {
		return tel;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @return the vehicleId
	 */
	public String getVehicleId() {
		return vehicleId;
	}

	/**
	 * @return the vehiclePicture
	 */
	public String getVehiclePicture() {
		return vehiclePicture;
	}

	/**
	 * @param applyReason
	 *            the applyReason to set
	 */
	public void setApplyReason(String applyReason) {
		this.applyReason = applyReason;
	}

	/**
	 * @param driverId
	 *            the driverId to set
	 */
	public void setDriverId(String driverId) {
		this.driverId = driverId;
	}

	/**
	 * @param fVApplySerI
	 *            the fVApplySerI to set
	 */
	public void setfVApplySerI(FVApplySerI fVApplySerI) {
		this.fVApplySerI = fVApplySerI;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param tel
	 *            the tel to set
	 */
	public void setTel(String tel) {
		this.tel = tel;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @param vehicleId
	 *            the vehicleId to set
	 */
	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	/**
	 * @param vehiclePicture
	 *            the vehiclePicture to set
	 */
	public void setVehiclePicture(String vehiclePicture) {
		this.vehiclePicture = vehiclePicture;
	}

}
